package com.jlc.book.shop.util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class JDBCUtil {
	
	static Connection con=null;
	static PreparedStatement ps=null;
	static ResultSet rs=null;
	
	
	static
	{
		try {
			Class.forName("com.mysql.jdbc.Driver");
		} catch (ClassNotFoundException e) {
			
			e.printStackTrace();
		}
	}

	public static Connection getConnection() {
		
		try {
			con=DriverManager.getConnection("jdbc:mysql://localhost:3306/jlconlinebookdb","root","root");
		} catch (SQLException e) {
		
			e.printStackTrace();
		}
		
		return con;
	}

	public static void cleanup(Connection con, PreparedStatement ps,
			ResultSet rs){
		try
		{
		if(con!=null)con.close();
		if(ps!=null)ps.close();
		if(rs!=null)ps.close();
		}
		catch (Exception e) {
			
			e.printStackTrace();
		}
		
	}
	

}
